import Vue from 'vue'
import Router from 'vue-router'
import store from '@/store'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/openlayers',
      component: () => import('./components/OpenLayers.vue')
    },
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      component: () => import('./views/Login.vue')
    },
    {
      path: '/',
      component: () => import('./views/Layout.vue'),
      children: [
        {
          path: 'home',
          component: () => import('./views/home/Home.vue')
        },
        {
          path: 'homeNew',
          component: () => import('./views/home/HomeNew.vue')
        },
        // config
        {
          path: 'config/remote',
          component: () => import('./views/config/remote/Remote.vue')
        },
        {
          path: 'config/antenna',
          component: () => import('./views/config/antenna/Antenna.vue')
        },
        // {
        //   path: 'config/center',
        //   component: () => import('./views/config/center/Center.vue'),
        //   children: [
        //     // {
        //     //   path: 'centerStation',
        //     //   components: () => import('./views/config/center/CenterStation.vue')
        //     // },
        //     {
        //       path: 'antenna',
        //       component: () => import('./views/config/center/Antenna.vue')
        //     },
        //     {
        //       path: 'ccu',
        //       component: () => import('./views/config/center/Ccu.vue')
        //     },
        //     {
        //       path: 'cu',
        //       component: () => import('./views/config/center/Cu.vue')
        //     }
        //   ]
        // },
        // new center
        // {name:'center/antenna',imgurl:antenna,titel:this.$t('message.center.Menu.menu1')},
        // {name:'center/nat',imgurl:nat,titel:this.$t('message.center.Menu.menu2')},
        // {name:'center/router',imgurl:router,titel:this.$t('message.center.Menu.menu3')},
        // {name:'center/accessterminal',imgurl:accessterminal,titel:this.$t('message.center.Menu.menu4')}
        {
          path: 'config/center',
          component: () => import('./views/config/center/index.vue'),
          children:[
            {
              path:"antenna",
              component:()=>import('./views/config/center/sam/Antenna.vue')
            },
            {
              path:"nat",
              component:()=>import('./views/config/center/sam/Nat.vue')
            },
            {
              path:"router",
              component:()=>import('./views/config/center/sam/Router.vue')
            },
            {
              path:"accessterminal",
              component:()=>import('./views/config/center/sam/accessterminal.vue')
            }
          ]
        },
        {
          path: 'config/subscribe',
          component: () => import('./views/config/subscribe/Subscribe.vue')
        },
        {
          path: 'config/p2p',
          component: () => import('./views/config/p2p/P2P.vue')
        },
        {
          path: 'config/multicast',
          component: () => import('./views/config/multicast/Multicast.vue')
        },
        {
          path: 'config/virtualSubnet',
          component: () => import('./views/config/virtualSubnet/VirtualSubnet.vue')
        },
        {
          path: 'config/resource',
          component: () => import('./views/config/satelliteResource/Resource.vue')
        },
        {
          path: 'config/accessPlan',
          component: () => import('./views/config/accessPlan/AccessPlan.vue')
        },
        // data
        {
          path: 'data/runningLog',
          component: () => import('./views/data/runningLog/RunningLog.vue')
        },
        {
          path: 'data/communicationLog',
          component: () => import('./views/data/communicationLog/CommunicationLog.vue')
        },
        {
          path: 'data/callLog',
          component: () => import('./views/data/callLog/CallLog.vue')
        },
        {
          path: 'data/snrLog',
          component: () => import('./views/data/snrLog/SnrLog.vue')
        },
        {
          path: 'data/operationLog',
          component: () => import('./views/data/operationLog/OperationLog.vue')
        },
        {
          path: 'data/performanceLog',
          component: () => import('./views/data/performanceLog/PerformanceLog.vue')
        },
        // system
        {
          path: 'system/networkParameters',
          component: () => import('./views/system/networkParameters/NetworkParameters.vue')
        },
        {
          path: 'system/ltlManage',
          component: () => import('./views/system/ltlManage/LtlManage.vue')
        },
        {
          path: 'system/userManage',
          component: () => import('./views/system/userManage/UserManage.vue')
        },
        {
          path: 'system/cpm',
          component: () => import('./views/system/cpm/Cpm.vue')
        },
        {
          path: 'system/devicetopology',
          component: () => import('./components/DeviceTopology.vue')
        }
      ]
    },
    {
      path: '*',
      component: () => import('./views/NotFound404')
    }
  ]
})

// 导航守卫
router.beforeEach((to, from, next) => {
  console.log("判断to.query.uid");
  console.log(to);
  console.log(from.query.uid);
  console.log(to.query);
  if (to.query.uid) {
    store.commit('setNetworkControlProgramUID', to.query.uid)
  }
  next()
})

export default router
